package cn.qyd;

/**
 * @author 邱运铎
 * @date 2024-03-09 15:54
 */
public class Demo3 {
    public static void main(String[] args) {
        System.out.println("从前有座灵剑山".substring(2));
        System.out.println("helloworld".substring(2));
        System.out.println(testMethod());
        String str = "从前有座灵剑山";

//        String str1 = "ni" + "hao" + new String("邱运铎");
//        String str2 = new String("nihao");
//        String str3 = str2.intern();
//        String str4 = str1.intern();
        String str5 = new String("ni") + new String("hao");
        String str6 = str5.intern();
//        System.out.println(str2 == str3);
//        System.out.println(str3 == "nihao");
//        System.out.println(str1 == str4);
        System.out.println(str5 == str6);

        String a = "abc";
        String b = "abc";
        String c = "a" + "b" + "c";
        String d = "a" + "bc";
        String e = "ab" + "c";
        String f = "a";
        String g = f + "bc";

        System.out.println(a == b);
        System.out.println(a == c);
        System.out.println(a == d);
        System.out.println(a == e);
        System.out.println(c == d);
        System.out.println(b == f);
        System.out.println(a == g);

    }

    public static int testMethod() {
        int a = 1;
        try{
            a = 2;
            return a;
        }catch (Exception e) {
            System.out.println("catch");
        } finally {
            a=3;
            System.out.println("i am finally ");
        }

        return a;
    }
}
